package com.jrx.anytxn.transaction.job.dailyAccount.step;

import com.jrx.anytxn.transaction.constant.TransBizConstant;
import com.jrx.anytxn.transaction.entity.TlDisbursementLog;
import com.jrx.anytxn.transaction.enums.DailyAccountEnum;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.batch.MyBatisPagingItemReader;

import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 读取日终T24核心汇总记账未记账放款记录
 *
 * @Author yhy
 * @Date 2023/4/29 10:39
 */
public class DailyAccountInitReader extends MyBatisPagingItemReader<TlDisbursementLog> {

    /**
     * 获取日终T24核心汇总记账放款记录
     *
     * @param businessDate 当前业务日期
     * @param sqlSessionFactory  sql工厂对象
     * @param pageSize 分页参数
     */
    public DailyAccountInitReader(Date businessDate, SqlSessionFactory sqlSessionFactory, Integer pageSize){
        setSaveState(false);
        setPageSize(pageSize);
        setSqlSessionFactory(sqlSessionFactory);
        setQueryId("com.jrx.anytxn.transaction.mapper.ext.ExtTlDisbursementLogMapper.selectDailyT24NotAccountData");

        Map<String, Object> map = new HashMap<>();
        // 上一业务日期
        map.put("businessDate",businessDate);
        // 租户id
        map.put("tenantId", TransBizConstant.DEFAULT_TENANT_ID);
        // 日终T24核心汇总记账产品列表
        map.put("productIds", Arrays.asList(DailyAccountEnum.T24_PRODUCTID.getCode().split(",")));
        // 收款账户类型(0-本行，1-他行)
        map.put("payeeAccountType", TransBizConstant.CARD_TYPE_1);
        // 日终T24核心汇总记账状态 S-记账成功，F-记账失败，O-记账状态未知，默认D-未记账
        map.put("keepAccountStatusList",Arrays.asList(TransBizConstant.DISBURSEMENT_LOG_SUM_STATUS_S,TransBizConstant.DISBURSEMENT_LOG_SUM_STATUS_O));
        setParameterValues(map);
    }
}
